//
//  TTLeadingLabelView.m
//  TaoTuo
//
//  Created by LG on 2020/9/5.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTLeadingLabelView.h"

@interface TTLeadingLabelView ()

@property (nonatomic, strong) UILabel *leftLabel;
@property (nonatomic, strong) UIButton *btn;
@property (nonatomic, strong) UILabel *rightLabel;

@end

@implementation TTLeadingLabelView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        [self setupSubviews];
        
    }
    return self;
}

- (void)setTitle:(NSString *)title titleColor:(UIColor *)titleColor imageName:(NSString *)imageName
{
    [self.btn setTitle:title forState:UIControlStateNormal];
    [self.btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [self.btn setTitleColor:titleColor forState:UIControlStateNormal];
    
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self);
    }];
    
    [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.leftLabel.mas_right);
    }];
    
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.btn.mas_right);
    }];
    
    [self layoutIfNeeded];
    self.width = self.rightLabel.right;
    
}

- (void)setupSubviews
{
    _leftLabel = [UILabel labelWithTitle:@"(" color:UIColorHex(5F5E5E) fontSize:13];
    [self addSubview:_leftLabel];
    
    
    _btn = [UIButton createButtonWithTitle:@"" titleColor:UIColor.blackColor titleFont:[UIFont systemFontOfSize:13] backgroundColor:nil target:nil action:nil];
    [self addSubview:_btn];
    
    _rightLabel = [UILabel labelWithTitle:@")" color:UIColorHex(5F5E5E) fontSize:13];
    [self addSubview:_rightLabel];
    
}


@end
